<!DOCTYPE HTML>
<html>
<head>
    <title>安置帮教帮教管理--帮教页面</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css"/>
    <link href="/static/css/default.css" rel="stylesheet" type="text/css"/>
    <script src="/static/js/common/common.js" type="text/javascript"></script>
</head>
<style>
    .delBtn {
        border: 1px solid #ff2120;
        border-radius: 10px;
        font-size: 8px;
        line-height: 20px;
        font-weight: bold;
        color: #ff4634;
    }
    .editBtn {
        border: 1px solid #018d00;
        border-radius: 10px;
        font-size: 8px;
        line-height: 20px;
        font-weight: bold;
        color: #00a60a;
    }
</style>
<body onload="onLoad()">
<div class="mini-fit" style="padding-top: 20px;margin-bottom: 45px;">
    <input id="pp" name="pp" class="mini-hidden" value="${pp!''}" style="width: 100%;" readonly/>
    <input id="priNum" name="priNum" class="mini-hidden" value="${priNum!''}" style="width: 100%;" readonly/>
    <div style="padding-left:30px; ">
        <form id="form1" method="post">
            <!-- 用户 编辑框START-->
            <div id="editform1" class="form">
                <input id="bfPid" name="priNum" class="mini-hidden" value="${priNum!''}" style="width: 100%;"
                       readonly/>
                <input id="bfId" name="id" class="mini-hidden" value="${bfId!''}" style="width: 100%;" readonly/>
                <table class="form-table" width="100%" cellspacing="8">

                    <tr>
                        <td width="13%" align="right" style="line-height: 40px;padding-top: 10px;"><font color="#dc143c">*</font>帮扶时间:</td>
                        <td width="87%">
                            <input class="mini-datepicker" value="${dateBangfu!''}" id="dateBangfu" name="dateBangfu" allowInput="false"
                                   required="true" ondrawdate="onDrawDate"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="13%" align="right"><font color="#dc143c">*</font>帮扶内容:</td>
                        <td class="input">
                            <input name="jdanzhi" id="jdanzhi" truevalue="1" falsevalue="0" class="mini-checkbox"
                                   value="${jdanzhi!''}" text="就学" onvaluechanged="checkboxOnclick(jdanzhi)"/>
                            <input name="zinvjiuxue" id="zinvjiuxue" truevalue="1" falsevalue="0" class="mini-checkbox"
                                   value="${zinvjiuxue!''}" text="子女就学" onvaluechanged="checkboxOnclick(zinvjiuxue)"/>
                            <input name="swjm" id="swjm" class="mini-checkbox" truevalue="1" falsevalue="0"
                                   value="${swjm!''}" text="工商登记税务减免(创业)" onvaluechanged="checkboxOnclick(swjm)"/>
                            <input name="zhiyezhidao" id="zhiyezhidao" truevalue="1" falsevalue="0"
                                   class="mini-checkbox" value="${zhiyezhidao!''}" text="免费职业指导和职业介绍(公共就业服务机构)"
                                   onvaluechanged="checkboxOnclick(zhiyezhidao)"/>
                            <input name="jiuyeyuanzhu" id="jiuyeyuanzhu" truevalue="1" falsevalue="0"
                                   class="mini-checkbox" value="${jiuyeyuanzhu!''}" text="就业援助" onvaluechanged="checkboxOnclick(jiuyeyuanzhu)"/><br/>
                            <input name="gongshangxindai" id="gongshangxindai" truevalue="1" falsevalue="0"
                                   class="mini-checkbox" value="${gongshangxindai!''}"
                                   text="工商、人社办理执照和人员培训支持，金融信贷支持、税收优惠(自主创业，自主谋业)" onvaluechanged="checkboxOnclick(gongshangxindai)"/>
                            <span id="errspan" class="diy_err" title="不能为空" data-placement="right"></span>
                        </td>
                    </tr>
                    <tr>
                        <td width="13%" align="right" style="line-height: 30px;">是否跟踪帮教工作:</td>
                        <td class="input">
                            <input name="bang" id="bang" class="mini-checkbox" style="line-height: 20px;" truevalue="1"
                                   falsevalue="0"
                                   value="${bang!''}" text="跟踪帮教" onvaluechanged="setFollowWork"/>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
        <form id="form2" method="post">
            <!-- 用户 编辑框START-->
            <div id="fileform2" class="form" style="width: 100%">
                <table class="form-table" width="100%" cellspacing="8">
                    <tr>
                        <td width="13%" align="right">
                            附件上传:
                        </td>
                        <td width="87%">
                            <input type="button" value="上传附件" onclick="onFileUpload('14')">
<#--                            <span  style="color: #8B8B8B" >支持扩展名:.rar .zip .doc .docx .xls .xlsx .pdf .jpg...</span>-->
                            <span id="msg1"></span>
                            <div><b>支持扩展名:</b>.rar .zip .doc .docx .xls .xlsx .pdf .jpg</div>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
    </div>
    <div id="followWork" style="display: none;padding-left:50px; ">
        <h5 style="font-size: 19px;font-weight: bold; ">跟踪帮教工作</h5>
        <span>1、地方党政组织和家庭教育</span>
        <form id="form_dz" method="post">
            <div id="editform_dz" class="form">
                <input id="dzPid" name="priNum" class="mini-hidden" value="${priNum!''}" style="width: 100%;"
                       readonly/>
                <input id="dzId" name="dzId" class="mini-hidden" value="${dzId!''}" style="width: 100%;" readonly/>
                <table class="form-table" width="100%" cellspacing="8">

                    <tr>
                        <td width="13%" align="right" style="line-height: 30px;padding-top: 10px;">帮扶时间:</td>
                        <td width="87%">
                            <input class="mini-datepicker" value="${dateGljy!''}" id="dateGljy" name="dateGljy" allowInput="false" ondrawdate="onDrawDate"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="13%" align="right">帮扶内容:</td>
                        <td class="input">
                            <input id="dangzhengRemark" name="dangzhengRemark" class="mini-textarea"
                                   emptyText="请输入内容(0-100):"
                                   value="${dangzhengRemark!''}" style="width:600px; "/>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
        <form id="form_dz_fj" method="post">
            <div id="fileform_dz" class="form" style="width: 100%">
                <table class="form-table" width="100%" cellspacing="8">
                    <tr>
                        <td width="13%" align="right" style="line-height: 50px;">
                            上传附件:
                        </td>
                        <td width="87%">
                            <input type="button" value="上传附件" onclick="onFileUpload('15')">
<#--                            <span  style="color: #8B8B8B" >支持扩展名:.rar .zip .doc .docx .xls .xlsx .pdf .jpg...</span>-->
                            <span id="msg2"></span>
                            <div><b>支持扩展名:</b>.rar .zip .doc .docx .xls .xlsx .pdf .jpg</div>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
        <span>2、社会组织帮教</span>
        <form id="form_shzz" method="post">
            <!-- 用户 编辑框START-->
            <div id="editform_shzz" class="form">
                <input id="shzzPid" name="priNum" class="mini-hidden" value="${priNum!''}" style="width: 100%;"
                       readonly/>
                <input id="shzzId" name="shzzId" class="mini-hidden" value="${shzzId!''}" style="width: 100%;"
                       readonly/>
                <table class="form-table" width="100%" cellspacing="8">

                    <tr>
                        <td width="13%" align="right" style="line-height: 30px;padding-top: 10px;">帮扶时间:</td>
                        <td width="87%" colspan="2">
                            <input class="mini-datepicker" value="${time!''}" id="time" name="time" allowInput="false" ondrawdate="onDrawDate"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="13%" align="right" style="line-height: 30px;padding-top: 10px;">组织类型:</td>
                        <td width="17%">
                            <input class="mini-combobox" value="${zzlx!''}" textField="name" valueField="id"
                                   onvaluechanged="onShzzChanged"
                                   data="[{ id: 1, name: '政治组织' },{ id: 2, name: '经济组织' },{ id: 3, name: '文化组织' },{ id: 4, name: '其他' } ]"
                                   emptyText="请选择" id="zzlx" name="zzlx"/>
                        </td>
                        <td width="70%">
                            组织名称:
                            <input class="mini-combobox" emptyText="请选择" textField="text" valueField="id"
                                   value="${zzmc!''}"
                                   url="/azbj/azbjgl/bjgzgl/getShgyzzInfoList?zzType=${zzlx!''}" id="zzmc" name="zzmc"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="13%" align="right">帮扶内容:</td>
                        <td class="input" colspan="2">
                            <input id="qkjj" name="qkjj" class="mini-textarea" emptyText="请输入内容(0-100):"
                                   value="${qkjj!''}" style="width:600px; "/>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
        <form id="form_shzz_fj" method="post">
            <!-- 用户 编辑框START-->
            <div id="fileform_shzzfj" class="form" style="width: 100%">
                <table class="form-table" width="100%" cellspacing="8">
                    <tr>
                        <td width="13%" align="right" style="line-height: 50px;">
                            上传附件:
                        </td>
                        <td width="87%">
                            <input type="button" value="上传附件" onclick="onFileUpload('17')">
<#--                            <span  style="color: #8B8B8B" >支持扩展名:.rar .zip .doc .docx .xls .xlsx .pdf .jpg...</span>-->
                            <span id="msg3"></span>
                            <div><b>支持扩展名:</b>.rar .zip .doc .docx .xls .xlsx .pdf .jpg</div>
                        </td>
                    </tr>
                </table>
            </div>
        </form>

        <span>3、志愿者帮教</span>
        <form id="form_zyz" method="post">
            <!-- 用户 编辑框START-->
            <div id="editform_zyz" class="form">
                <input id="zyzPid" name="priNum" class="mini-hidden" value="${priNum!''}" style="width: 100%;"
                       readonly/>
                <input id="zId" name="id" class="mini-hidden" value="${zId!''}" style="width: 100%;" readonly/>
                <table class="form-table" width="100%" cellspacing="8">

                    <tr>
                        <td width="13%" align="right" style="line-height: 30px;padding-top: 10px;">帮扶时间:</td>
                        <td width="87%">
                            <input class="mini-datepicker" value="${dateZyzjz!''}" id="dateZyzjz" name="dateZyzjz" allowInput="false" ondrawdate="onDrawDate"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="13%" align="right" style="line-height: 30px;padding-top: 10px;">志愿者名称:</td>
                        <td width="67%">
                            <input class="mini-combobox" url="/azbj/bjdxInfo/setBjxz/getZyzList" value="${zyzid!''}" textField="text" valueField="id" id="zyzid" name="zyzid"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="13%" align="right">帮扶内容:</td>
                        <td class="input" colspan="2">
                            <input id="remark" name="remark" class="mini-textarea" emptyText="请输入内容(0-100):"
                                   value="${remark!''}" style="width:600px "/>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
        <form id="form_zyz_fj" method="post">
            <!-- 用户 编辑框START-->
            <div id="fileform_zyz_fj" class="form" style="width: 100%">
                <table class="form-table" width="100%" cellspacing="8">
                    <tr>
                        <td width="13%" align="right" style="line-height: 50px;">
                            上传附件:
                        </td>
                        <td width="87%">
                            <input type="button" value="上传附件" onclick="onFileUpload('18')">
<#--                            <span  style="color: #8B8B8B" >支持扩展名:.rar .zip .doc .docx .xls .xlsx .pdf .jpg...</span>-->
                            <span id="msg4"></span>
                            <div><b>支持扩展名:</b>.rar .zip .doc .docx .xls .xlsx .pdf .jpg</div>
                        </td>
                    </tr>
                </table>
            </div>
        </form>


        <span>4、排查</span>
        <form id="form_pc" method="post">
            <!-- 用户 编辑框START-->
            <div id="editform_pc" class="form">
                <input id="pcPid" name="priNum" class="mini-hidden" value="${priNum!''}" style="width: 100%;"
                       readonly/>
                <input id="pcId" name="id" class="mini-hidden" value="${pcId!''}" style="width: 100%;" readonly/>
                <table class="form-table" width="100%" cellspacing="8">

                    <tr>
                        <td width="13%" align="right" style="line-height: 30px;padding-top: 10px;">帮扶时间:</td>
                        <td width="87%">
                            <input class="mini-datepicker" value="${paitime!''}" id="paitime" name="paitime" allowInput="false" ondrawdate="onDrawDate"/>
                        </td>
                    </tr>
                  <tr>
                      <td width="13%" align="right" style="line-height: 30px;padding-top: 10px;">排查状况:</td>
                      <td width="87%">
                          <input class="mini-combobox" value="${paizhuang!''}" id="paizhuang" name="paizhuang"
                                 textField="name" valueField="id"
                                 data="[{ id: 1, name: '有矛盾纠纷' },{ id: 2, name: '有重新犯罪倾向' },{ id: 3, name: '失联' },{ id: 4, name: '找回' },{ id: 5, name: '其他' } ]"/>
                      </td>
                  </tr>
                    <tr>
                        <td width="13%" align="right">备&emsp;&emsp;注:</td>
                        <td class="input" colspan="2">
                            <input id="paibei" name="paibei" class="mini-textarea" emptyText="请输入内容(0-100):"
                                   value="${paibei!''}" style="width:600px "/>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
        <form id="form_pc_fj" method="post">
            <!-- 用户 编辑框START-->
            <div id="fileform_pc_fj" class="form" style="width: 100%">
                <table class="form-table" width="100%" 8>
                    <tr>
                        <td width="13%" align="right" style="line-height: 50px;">
                            上传附件:
                        </td>
                        <td width="87%">
                            <input type="button" value="上传附件" onclick="onFileUpload('19')">
<#--                            <span  style="color: #8B8B8B" >支持扩展名:.rar .zip .doc .docx .xls .xlsx .pdf .jpg...</span>-->
                            <span id="msg5"></span>
                            <div><b>支持扩展名:</b>.rar .zip .doc .docx .xls .xlsx .pdf .jpg</div>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
    </div>
</div>

<div style="width: 100%;position: absolute;bottom: 0;line-height: 45px;border-top:1px solid #dfdfdf;text-align: center">
    <a class="mini-button" iconCls="fa-save" plain="true" onclick="saveData()">保存</a>
    <a class="mini-button" iconCls="fa-undo" plain="true" onclick="close('close')">取消</a>
</div>

<script type="text/javascript">
    mini.parse();
    var priNumObj = mini.get("priNum");
    var ppObj = mini.get("pp");
    var form1 = new mini.Form("form1");//帮扶信息
    var form_dz = new mini.Form("form_dz");//党政
    var form_shzz = new mini.Form("form_shzz");//社会组织
    var form_zyz = new mini.Form("form_zyz");//志愿者
    var form_pc = new mini.Form("form_pc");//排查
    var bangObj = mini.get("bang");
    var fWObj = document.getElementById("followWork");
    var zzmcObj = mini.get("zzmc");
    var zzlxObj = mini.get("zzlx");
    var zyzidObj = mini.get("zyzid");

    function onLoad() {
        setFollowWork();
        //显示上传多少条的文件数量
        $("#msg1").text("上传成功" + ${count1} + "条!")
        $("#msg2").text("上传成功" + ${count2} + "条!")
        $("#msg3").text("上传成功" + ${count3} + "条!")
        $("#msg4").text("上传成功" + ${count4} + "条!")
        $("#msg5").text("上传成功" + ${count5} + "条!")
    }

    function showGrid(e) {
        if (e == "jiuye") {
            document.getElementById("jiuye").style.display = "block";
            document.getElementById("jiuyeId").style.color = "#2e83ff";
            document.getElementById("peixun").style.display = "none";
            document.getElementById("peixunId").style.color = "black";
            document.getElementById("chuangye").style.display = "none";
            document.getElementById("chuangyeId").style.color = "black";
        } else if (e == "peixun") {
            document.getElementById("peixun").style.display = "block";
            document.getElementById("peixunId").style.color = "#2e83ff";
            document.getElementById("jiuye").style.display = "none";
            document.getElementById("jiuyeId").style.color = "black";
            document.getElementById("chuangye").style.display = "none";
            document.getElementById("chuangyeId").style.color = "black";
        } else if (e == "chuangye") {
            document.getElementById("chuangye").style.display = "block";
            document.getElementById("chuangyeId").style.color = "#2e83ff";
            document.getElementById("jiuye").style.display = "none";
            document.getElementById("jiuyeId").style.color = "black";
            document.getElementById("peixun").style.display = "none";
            document.getElementById("peixunId").style.color = "black";
        }
    }

    function setFollowWork() {
        var bangVal = bangObj.getValue();
        if (bangVal == "1") {
            fWObj.style.display = "block";
        } else {
            fWObj.style.display = "none";
        }
    }

    function onShzzChanged() {
        var zzType = zzlxObj.getValue();
        var url = "/azbj/azbjgl/bjgzgl/getShgyzzInfoList?zzType=" + zzType;
        zzmcObj.setUrl(url);
        zzmcObj.select(0);
    }
    function onDrawDate(e) {
        var date = e.date;
        var d = new Date();
        if (date.getTime() > d.getTime()) {
            e.allowSelect = false;
        }
    }
    function checkboxOnclick(checkbox){
        if (mini.get(checkbox).getValue() == 1){
            document.getElementById("errspan").removeAttribute("style");
        } else {
            var jdanzhi = mini.get("jdanzhi").getValue();
            var zinvjiuxue = mini.get("zinvjiuxue").getValue();
            var swjm = mini.get("swjm").getValue();
            var zhiyezhidao = mini.get("zhiyezhidao").getValue();
            var jiuyeyuanzhu = mini.get("jiuyeyuanzhu").getValue();
            var gongshangxindai = mini.get("gongshangxindai").getValue();
            if(jdanzhi==0 && zinvjiuxue==0 && swjm==0 && zhiyezhidao==0 && jiuyeyuanzhu==0 && gongshangxindai==0){
                document.getElementById("errspan").style="display:inline";
            }
        }
    }


    //  14帮扶附件上传 15帮扶-党政家庭教育附件 16 帮扶-走访附件 17帮扶-社会组织 18帮扶-志愿者 19 帮扶-排查 )
    function saveData() {
        var bjId = ppObj.getValue();
        var priNum = priNumObj.getValue();
        form1.validate();
        if (form1.isValid() == false) {
            return;
        }

        var jdanzhi = mini.get("jdanzhi").getValue();
        var zinvjiuxue = mini.get("zinvjiuxue").getValue();
        var swjm = mini.get("swjm").getValue();
        var zhiyezhidao = mini.get("zhiyezhidao").getValue();
        var jiuyeyuanzhu = mini.get("jiuyeyuanzhu").getValue();
        var gongshangxindai = mini.get("gongshangxindai").getValue();
        if(jdanzhi==0 && zinvjiuxue==0 && swjm==0 && zhiyezhidao==0 && jiuyeyuanzhu==0 && gongshangxindai==0){
            document.getElementById("errspan").style="display:inline";
            return;
        }

        saveBangFu(bjId, priNum);
        var bang = bangObj.getValue();
        if (bang == 1) {
            saveDangzheng(bjId, priNum);
            /* saveZouFangInfo(bjId, priNum);*/
            saveShzzInfo(bjId, priNum);
            saveZyzInfo(bjId, priNum);
            savePcInfo(bjId, priNum);
        }
        mini.alert("保存成功","成功",function(){
            window.CloseOwnerWindow('ok')
        })
    }

    //保存帮扶信息 taskid=14
    function saveBangFu(bjId, priNum) {
        //保存帮教信息及附件
        var data = form1.getData();
        data.pp = bjId;
        var json = mini.encode(data);
        $.ajax({
            url: "/azbj/azbjgl/bjgzgl/saveBjInfo",
            type: "post",
            data: {data: json},
            async: false,
            success: function (result) {

            }
        });
        return bjId;
    }

    //保存党政教育信息及附件 taskid=15
    function saveDangzheng(bjId, priNum) {
        var data = form_dz.getData();
        data.pp = bjId;
        data.fujian = 15;
        data.id = mini.get("dzId").getValue();
        var json = mini.encode(data);
        $.ajax({
            url: "/azbj/azbjgl/bjgzgl/saveBjDzInfo",
            type: "post",
            async: false,
            data: {data: json},
            success: function (result) {
            }
        });
    }

    //保存社会组织信息及附件 taskid=17
    function saveShzzInfo(bjId, priNum) {
        var data = form_shzz.getData();
        data.pp = bjId;
        data.fujian = 17;
        data.id = mini.get("shzzId").getValue();
        var json = mini.encode(data);
        $.ajax({
            url: "/azbj/azbjgl/bjgzgl/saveBjShzzInfo",
            type: "post",
            async: false,
            data: {data: json},
            success: function (result) {

            }
        });
    }

    //保存志愿者信息及附件 taskid=18
    function saveZyzInfo(bjId, priNum) {
        var data = form_zyz.getData();
        data.pp = bjId;
        data.fujian = 18;
        data.zyzname = zyzidObj.getText();
        var json = mini.encode(data);
        $.ajax({
            url: "/azbj/azbjgl/bjgzgl/saveBjZyzInfo",
            type: "post",
            async: false,
            data: {data: json},
            success: function (result) {

            }
        });
    }

    //保存排查信息及附件 taskid=19
    function savePcInfo(bjId, priNum) {
        var data = form_pc.getData();
        data.pp = bjId;
        data.fujian = 19;
        var json = mini.encode(data);
        $.ajax({
            url: "/azbj/azbjgl/bjgzgl/saveBjPcInfo",
            type: "post",
            async: false,
            data: {data: json},
            success: function (result) {
            }
        });
    }

    function refreshPage(action) {
        if (action == "close") {
            window.location.reload();
        }
    }


    function close(action) {
        if (window.CloseOwnerWindow) {
            window.CloseOwnerWindow(action);
        } else {
            window.close();
        }
    }

    // 获取页面的id priNum等
    function GetData() {
        var idval = ppObj.getValue();
        var priNum1 = priNumObj.getValue();
        var data = {priNum: priNum1, id: idval, taskId: ['14','15','17','18','19']};
        return data;
    }

    //附件上传
    function onFileUpload(taskid) {
        var idval = ppObj.getValue();
        if(!idval){
            idval = 'noid';
        }
        var prival = priNumObj.getValue();
        var url = "/upload/user/uploadAppendixfile/view?1=1&id="+idval+"&priNum="+prival+"&taskId=" + taskid;
        commonEdit(url, null, null,600, 400, true,true,true,callback);
        // 回调函数
        function callback() {
            $.ajax({
                url: "/upload/downloadAppendixFile/getCountById?1=1&priNum=" + prival + "&taskId=" + taskid + "&id=" + idval,
                type: "get",
                success: function (success) {
                    if (taskid == '14'){
                        $("#msg1").text("上传成功" + success.data + "条!");
                    }else if(taskid == '15'){
                        $("#msg2").text("上传成功" + success.data + "条!");
                    }else if (taskid == '17'){
                        $("#msg3").text("上传成功" + success.data + "条!");
                    }else if (taskid == '18'){
                        $("#msg4").text("上传成功" + success.data + "条!");
                    }else if (taskid == '19'){
                        $("#msg5").text("上传成功" + success.data + "条!");
                    }
                }
            })
            grid.reload();
        }
    }
</script>
</body>
</html>